﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Questionary.Model
{
    public class ActiveItem
    {
        /// <summary>
        /// 问卷ID
        /// </summary>
        public int ID { get; set; }
        /// <summary>
        /// 学校名
        /// </summary>
        public string SchoolName { get; set; }
        /// <summary>
        /// 姓名
        /// </summary>
        public string Name { get; set; }
        /// <summary>
        /// 记录IP
        /// </summary>
        public string IP { get; set; }
        /// <summary>
        /// 答题时间
        /// </summary>
        public DateTime CreateTime { get; set; }
        /// <summary>
        /// 答题内容
        /// </summary>
        public List<AnswerItem>  Answers
        {
            get { return _answers; }
            set { _answers = value; }
        }
        private List<AnswerItem> _answers = new List<AnswerItem>();

        public bool IsValid()
        {
            return !string.IsNullOrEmpty(SchoolName)
                && !string.IsNullOrEmpty(Name)
                && Answers != null
                && Answers.All(tmp => !(string.IsNullOrEmpty(tmp.Content) && (tmp.Selections == null || tmp.Selections.Count == 0)));
        }
    }
}